﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using ProgNetComponentsDx.Controls.Design.Editors;
using ProgNetComponentsDx.Controls.Editors;

namespace ProgNetComponentsDx.Controls.Design.TypeConverters
{
    public class TimeDurationEditTypeConverter : TypeConverter
    {
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            return base.ConvertFrom(context, culture, value);
        }

        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (context != null && context.Instance is TimeDurationEdit)
            {
                return TimeMaskManager.GetString((context.Instance as TimeDurationEdit).Properties, value);
            }
            else if (context != null && context.Instance is RepositoryItemTimeDurationEdit)
            {
                return TimeMaskManager.GetString((context.Instance as RepositoryItemTimeDurationEdit), value);
            }
            
            return base.ConvertTo(context, culture, value, destinationType);
        }
    }
}
